package com.yenlien.traceyun.breed.dao;

import com.alibaba.fastjson.JSONObject;
import com.yenlien.traceyun.breed.entity.MotionTrail;
import com.yenlien.traceyun.webase.dao.BaseJpaDao;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface MotionTrailDao extends BaseJpaDao<MotionTrail> {

//    @Query(value = "select equipment_id,coordinate from t_breed_motion_trail group by equipment_id order by createtime desc", nativeQuery = true)
//	List<String> findAllCoordinate();

    @Query(value = "select t.equipment_id equipmentId,t.coordinate,d.seed_name seedName from t_breed_detail d inner join (select equipment_id, ANY_VALUE(coordinate) coordinate from t_breed_motion_trail group by equipment_id order by any_value(createtime) desc) as t where d.equipment_id = t.equipment_id", nativeQuery = true)
    List<JSONObject> findAllCoordinate();

}
